package com.ht.file.api;


import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import com.ht.common.core.constant.SecurityConstants;
import com.ht.common.core.constant.ServiceNameConstants;
import com.ht.common.core.domain.R;
import com.ht.file.api.dto.SysFileDto;
import com.ht.file.api.factory.RemoteFileFallbackFactory;

/**
 * 文件服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService {
    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<SysFileDto> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 通过文件Id获得文件base64数据
     *
     * @param fileId
     * @param source
     * @return
     */
    @PostMapping(value = "/getFileBase64Data/{fileId}")
    public R<SysFileDto> getFileBase64Data(@PathVariable("fileId") String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 通过文件Id获得文件nginx代理httpUrl
     *
     * @param fileId
     * @param source
     * @return
     */
    @PostMapping(value = "/getFileHttpUrl/{fileId}")
    public R<SysFileDto> getFileHttpUrl(@PathVariable("fileId") String fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
